package com.cmcc.xdr.util.sql;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.cmcc.pcap.jpcap.util.DateUtil;

import com.cmcc.xdr.entity.HttpEntity;


public class HttpsTcpConnectionSaveSqlUtil {
	private static Logger logger = LogManager.getLogger(HttpsTcpConnectionSaveSqlUtil.class);
	public static String sql(HttpEntity https,String taskId) {
		logger.debug("https sql list");
		String sql = "('" + https.getLength() + "','" + https.getLocalProvince() + "','" + https.getLocalCity()
			 	+ "','" + https.getOwnerProvince() + "','" + https.getOwnerCity() + "','" + https.getRoamingType()
			 	+ "','" + https.getInterFace() + "','" + https.getXdrId() + "','" + https.getAppType() + "','"
			 	+ DateUtil.format(https.getProcedureStartTime()) + "','" + DateUtil.format(https.getProcedureEndTime()) + "','" + https.getLongitude() + "','"
			 	+ https.getLatitude() + "','" + https.getHeight() + "','" + https.getCoordinateSystem() + "','" 
			 	+ https.getProtocolType() + "','" + https.getAppType() + "','" + https.getAppSubType() + "','" + https.getAppContent() + "','" 
			 	+ https.getAppStatus() + "','" + https.getIpAddressType() + "','" + https.getUserIpv4() + "','" + https.getUserIpv6()+ "','" 
			 	+ https.getUserPort() + "','" + https.getL4Protocal() + "','" + https.getAppServerIpIpv4() + "','" + https.getAppServerIpIpv6() + "','" 
			 	+ https.getAppServerPort() + "','" + https.getUlData() + "','" + https.getDlData() + "','" + https.getUlIpPacket() + "','" 
			 	+ https.getDlIpPacket() + "','" + https.getUpdura() + "','" + https.getDowndura() + "','" + https.getUlDisorderIpPacket()+ "','" 
			 	+ https.getDlDisorderIpPacket() + "','" + https.getUlRetransIpPacket() + "','" + https.getDlRetransIpPacket() + "','" 
			 	+ https.getTcpResponseTime() + "','" + https.getTcpAckTime() + "','" + https.getUlIpFragPackets() + "','" + https.getDlIpFragPackets() + "','"
			 	+ https.getFirstReqTime() + "','" + https.getFirstResponseTime() + "','" + https.getWindow() + "','" + https.getMss() + "','"
			 	+ https.getTcpSynNum()+ "','" + https.getTcpStatus() + "','" + https.getSessionEnd() + "','" + https.getTcpSynAckNum() + "','"
			 	+ https.getTcpAckNum() + "','" + https.getTcp12HandshakeStatus() + "','" + https.getTcp23HandshakeStatus() + "','" 
			 	+ https.getUlProbeid() + "','" + https.getUlLinkIndex() + "','"+ https.getDlProbeid() + "','" + https.getDlLinkIndex() + "','"
			 	+ https.getTransactionid() + "','" + https.getFlowControl() + "','"  + https.getUlAvgRtt() + "','" + https.getDwAvgRtt() + "','" + https.getUserAccount() + "','"
			 	+ https.getReferXdrId() + "','" + https.getHttpVersion() + "','" + https.getMessageType() + "','"  + https.getMessageStatus() + "','" + https.getFirstHttpResponseTime() + "','"
			 	+ https.getLastContentPacketTime() + "','" + https.getLastAckTime() + "','" + https.getHostLength() + "','"  + https.getHost() + "','" + https.getUriLength() + "','" 
			 	+ https.getUri() + "','" + https.getxOnlineHostLength() + "','" + https.getxOnlineHost() + "','"  + https.getUserAgentLength() + "','" + https.getUserAgent() + "','"
			 	+ https.getHttpContentType() + "','" + https.getReferUriLength() + "','" + https.getReferUri() + "','" + https.getCookieLength() + "','" + https.getCookie() + "','" 
			 	+ https.getContentLength() + "','" + https.getKeyWord() + "','" + https.getServiceBehaviorFlag() + "','" + https.getServiceCompFlag() + "','" + https.getServiceTime() + "','" 
			 	+ https.getIe() + "','" + https.getPortal() + "','" + https.getLocationLength() + "','" + https.getLocation() + "','" + https.getFirstRequest() + "','" + https.getUserAccountLogin() + "','" 
			 	+ https.getUriType() + "','" + https.getUriSubType() + "','" +taskId+"')";
		logger.debug("https sql list end");
		sql = sql.replaceAll("\'null\'", "null");
		return sql;
	}
}
